package api

import (
	"gin-skeleton/core/response"
	"gin-skeleton/etc"
	"gin-skeleton/support"
	"github.com/gin-gonic/gin"
)

type Home struct {
}

func (h Home) Index(c *gin.Context){
	support.Log().Info("测试消息")

	response.Api(c).SetMessage("操作成功").Success(gin.H{
		"name":    etc.Load().App.Name,
		"version": etc.Load().App.Version,
		"message": "hello world",
	})
}

func (h Home) Store(c *gin.Context)  {
	response.Api(c).SetMessage("操作失败").Fail(1)
}

func (h Home) Update(c *gin.Context) {
	// 参数错误
	err := &response.ParameterError
	err.FormatMessage("name")
	response.Api(c).Error(err)
}


